<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <title>教务综合管理系统</title>
    <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/demo.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/ready.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/ready.min.css}">
    <script type="text/javascript" th:src="@{/js/Vue.js}"></script>
    <!-- 引入组件库 -->
    <script type="text/javascript" th:src="@{/js/element-ui.js}"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" th:href="@{/css/element-ui.css}"/>

    <style>
        /** {*/
        /*    padding: 0px;*/
        /*    margin: 0px;*/
        /*}*/

        [v-cloak] {
            display: none !important;
        }
    </style>
</head>
<body>
<div class="wrapper" id="app" v-cloak>
    <!--    引入公共页面 public-index。html 的模块-->
    <div th:replace="admin/public-admin-index :: header"></div>

    <el-container style="height: 100%; border: 1px solid #eee">
        <div th:replace="admin/public-admin-index :: left"></div>


        <el-container>
            <el-main>
                <el-card class="box-card">

                    <div class="card-header">
                        <h5 class="card-title">修改密码</h5>
                    </div>
                    <div class="card-body">

                        <div class="form-group">
                            <label for="password1">新密码</label>
                            <input tabindex="1" v-model="pwd1" type="password" class="form-control" id="password1" placeholder="新密码" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;">
                        </div>
                        <div class="form-group">
                            <label for="password2">确认密码</label>
                            <input tabindex="2" v-model="pwd2" type="password" class="form-control" id="password2" placeholder="确认密码" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;">
                        </div>
                        <button tabindex="3" th:if="${session.ROLE=='admin'}" type="submit" class="btn btn-primary center-block" @click="adminUpdatePwd">确认修改</button>
                        <button tabindex="3" th:if="${session.ROLE=='sadmin'}" type="submit" class="btn btn-primary center-block" @click="sadminUpdatePwd">确认修改</button>
                    </div>

                </el-card>
            </el-main>
        </el-container>
    </el-container>

</div>
</body>
<script type="text/javascript" th:src="@{/webjars/jquery/1.9.1/jquery.js}"></script>
<script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/asserts/js/ready.min.js}"></script>
<script type="text/javascript" th:src="@{/js/axios.js}"></script>
<script th:inline="javascript">

    var basePath= /*[[${#httpServletRequest.getContextPath()}]]*/'ContextPath' ;

    var app = new Vue({
        el:"#app",
        data:{
            pwd1:"",
            pwd2:""
        },
        methods:{
            adminUpdatePwd(){
                if(this.pwd1!=this.pwd2){
                    alert("两次输入的密码不同");
                    return ;
                }
                axios.post(basePath+"/admin/updatePwd",{
                    pwd:this.pwd2
                }).then((r)=>{
                    console.log(r);
                    if(r.data.code == 100){
                        alert("修改成功,请重新登录");
                        window.location.href =basePath+"/admin/exit";
                    }else
                        alert("修改失败")
                });

            },
            sadminUpdatePwd(){
                if(this.pwd1!=this.pwd2){
                    alert("两次输入的密码不同");
                    return ;
                }
                axios.post(basePath+"/sadmin/updatePwd",{
                    "pwd":this.pwd2
                }).then((r)=>{
                    if(r.data.code == 100){
                        alert("修改成功,请重新登录");
                        window.location.href =basePath+"/admin/exit";
                    }else
                        alert("修改失败")
                });
            }
        }
    })

</script>



</html>